package com.example.test.entity;

import java.util.function.Supplier;

public class Parent<T> {

    private T first;

    private T second;

    public Parent(T first, T second) {
        this.first = first;
        this.second = second;
    }

    public static <T> Parent<T> makePare(Class<T> cl){
        try {
            return new Parent<>(cl.getConstructor().newInstance(),cl.getConstructor().newInstance());
        }catch (Exception e){
            return null;
        }
    }

    public static <T> Parent<T> makePare2(Supplier<T> supplier){
       return new Parent<>(supplier.get(),supplier.get());
    }

    public void sayHello(T value)
    {
        System.out.println("This is Parent Class, value is " + value);
    }

    public T getFirst() {
        return first;
    }

    public T getSecond() {
        return second;
    }
}
